package com.jiangman.weather.adapter;

import android.graphics.Color;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jiangman.weather.R;
import com.jiangman.weather.bean.WeatherForecast;

import java.util.ArrayList;
import java.util.List;

import cjh.weatherviewlibarary.WeatherView;
import util.WeatherUtils;

/**
 * Created by secoro on 2017/5/4.
 */

public class CompleteShowAdapter  extends BaseQuickAdapter<WeatherForecast,BaseViewHolder> {
    private int highestDegree, lowestDegree,weatherViewW;
    private List<WeatherForecast> datas = new ArrayList<>();
    public CompleteShowAdapter( List<WeatherForecast> data, int highestDegree, int lowestDegree, int weatherViewW) {
        super(R.layout.line_weather_item, data);
        this.datas = data;
        this.highestDegree = highestDegree;
        this.lowestDegree = lowestDegree;
        this.weatherViewW = weatherViewW;
    }

    @Override
    protected void convert(BaseViewHolder helper, WeatherForecast item) {
        int position=helper.getPosition();
        if (position == 0) {
            helper.setText(R.id.time_tv,"今天");
        } else if (position == 1) {
            helper.setText(R.id.time_tv,"明天");
        } else if (position == 2) {
            helper.setText(R.id.time_tv,"后天");
        } else {
            helper.setText(R.id.time_tv,item.getWeek());
        }
        String dayType =item.getWeatherStart();
        helper.setText(R.id.weather_tv,dayType);
        int iconResId = WeatherUtils.getWhiteIconIdByTypeName(dayType);
        if (iconResId != 0) {
            helper.setImageResource(R.id.weather_img,iconResId);
        } else {

        }

        WeatherView weatherView = helper.getView(R.id.weather_view);
        weatherView.setWH(240,240);
        weatherView.setDatas(datas,highestDegree,lowestDegree,position);
        weatherView.setBackgroundColor(Color.parseColor("#00000000"));


    }
}
